import Sequelize from 'sequelize'
import db from '../util/db'


import Model from './base'

class _Model extends Model {
}


_Model.init({
    // attributes
    name: {
        type: Sequelize.STRING,
        allowNull: false
    },
    introduction: {
        type: Sequelize.STRING,
    },
    price: {
        type: Sequelize.FLOAT,
        allowNull: false
    },
    retailPrice: {
        type: Sequelize.FLOAT,
    },
    sales: {
        type: Sequelize.INTEGER,
    },
    coverImage: {
        type: Sequelize.STRING,
        allowNull: false
    },
    clientId: {
        type: Sequelize.INTEGER,
        allowNull: false
    },
    skus: {
        type: Sequelize.ARRAY(Sequelize.INTEGER), //{id，options:[{id ,name,value}]}
    },
    images: {
        type: Sequelize.ARRAY(Sequelize.STRING),
    },
    optionValues: {
        type: Sequelize.ARRAY(Sequelize.INTEGER),
    },
    typeId: {
        type: Sequelize.INTEGER,
    },
    keywords: {
        type: Sequelize.STRING,
    },
    note: {
        type: Sequelize.STRING,
    },
    servicePromiseIds: {
        type: Sequelize.ARRAY(Sequelize.INTEGER),
    },
    categoryIds: {
        type: Sequelize.ARRAY(Sequelize.INTEGER),
    },
    useDefaultSku: {
        type: Sequelize.BOOLEAN,
    }
}, {
    sequelize: db,
    freezeTableName: true,
    modelName: 'product'
    // options
});

_Model.sync({force: false})
export default _Model
